import React from 'react';
import { Descriptions } from 'antd';

import { getDicByKey } from '@/support/common';
import PropTypes from 'prop-types';

export default class VehicleTab extends React.Component<any, any> {
  static contextTypes = {
    dicData: PropTypes.any,
  };
  componentDidMount() {}

  componentWillUnmount = () => {
    this.setState = (state, callback) => {
      return;
    };
  };

  render() {
    const { context } = this;
    const { data2, kmTotal, vehicleState, engineVo2 } = this.props;
    const data = data2 || {};
    const engineVo = engineVo2 || {};
    return (
      <>
        <Descriptions bordered size="small">
          <Descriptions.Item label="车辆状态">
            {vehicleState
              ? getDicByKey(this.context.dicData, 'vehicleState', `${vehicleState}`)
              : ''}
          </Descriptions.Item>
          <Descriptions.Item label="充电状态">
            {data.chargeStatus
              ? getDicByKey(context.dicData, 'chargeStatus', data.chargeStatus)
              : ''}
          </Descriptions.Item>
          <Descriptions.Item label="运行模式">
            {getDicByKey(context.dicData, 'operationMode', data.operationMode)}
          </Descriptions.Item>
          <Descriptions.Item label="车速(km/h)">{engineVo.vehSdp}</Descriptions.Item>
          <Descriptions.Item label="累计里程(km)">{kmTotal}</Descriptions.Item>
          <Descriptions.Item label="总电压(V)">
            {data.totalVoltage}
            {/* {`${data.totalVoltage}V`} */}
          </Descriptions.Item>
          <Descriptions.Item label="总电流(A)">
            {data.totalCurrent ? `${data.totalCurrent}` : ''}
          </Descriptions.Item>
          <Descriptions.Item label="SOC(%)">
            {data.soc ? getDicByKey(context.dicData, 'soc', data.soc) : ''}
          </Descriptions.Item>
          <Descriptions.Item label="DC-DC状态">
            {getDicByKey(context.dicData, 'dcStatus', data.dcStatus)}
          </Descriptions.Item>
          <Descriptions.Item label="挡位">
            {getDicByKey(context.dicData, 'gear', data.gearInfo?.gear)}
          </Descriptions.Item>
          <Descriptions.Item label="绝缘电阻(千欧)">
            {data.insulationResistance ? `${data.insulationResistance}` : ''}
          </Descriptions.Item>
          <Descriptions.Item label="加速踏板行程值(%)">
            {data.acceleratorPedalTravel
              ? getDicByKey(context.dicData, 'acceleratorPedalTravel', data.acceleratorPedalTravel)
              : ''}
          </Descriptions.Item>
          <Descriptions.Item label="制动踏板行程值(%)">
            {data.brakePedalStatus
              ? getDicByKey(context.dicData, 'brakePedalStatus', data.brakePedalStatus)
              : ''}
          </Descriptions.Item>
          <Descriptions.Item label=""></Descriptions.Item>
          <Descriptions.Item label=""></Descriptions.Item>
        </Descriptions>
      </>
    );
  }
}
